import javax.servlet.FilterChain;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebFilter;
import javax.servlet.http.HttpFilter;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;

@WebFilter(filterName = "Loginfilter")
public class loginfilter extends HttpFilter{
    @Override
    protected void doFilter(HttpServletRequest req, HttpServletResponse res, FilterChain chain)
            throws IOException, ServletException {
        System.out.println("LoginFilter");

        HttpSession session=req.getSession();

        //若未登录，重定向至莞工中央认证
        if(session.getAttribute("islogin")=="false"||session.getAttribute("islogin")==null){
            session.setAttribute("islogin","false");
//            RequestDispatcher rd=req.getRequestDispatcher("Login.jsp");
//            rd.forward(req,res);
        }else
        {
//            session.setAttribute("islogin","true");
        }
        chain.doFilter(req,res);
    }

    @Override
    public void destroy() {

    }
}
